<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String ctx = request.getContextPath();
    request.setAttribute("ctx", ctx);
%>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-1.8.2.min.js"></script>
    <script src="js/fileupload.js"></script>
    <script src="My97DatePicker/WdatePicker.js"></script>
    <script>
        $.ajax({
                   url:"brandlist.do",
                   success:function(obj) {
                       for (var i  of obj) {
                           $("[name='bid']").append(
                               "<option value='"+obj[i].bid+"'>"+obj[i].bname+"</option>"
                           )
                       }
                   },
            dataType: "json",
            type: "post"
              })
        function toadd() {
            var formData = new FormData($("form")[0])
            $.ajax({
                       url:"add.do",
                       type:"post",
                       data:formData,
                       dataType:"json",
                       success:function(obj) {
                            if (obj>0){
                                alert("添加成功");
                                location="list.do";
                            }
                       },
                processData: false,
                contentType:false
                  })
        }
    </script>
</head>
<body>
    商品名称:<input type="text" name="sname"><br>
    商品品牌:<input type="text" name="style"><br>
    规格型号:<input type="text" name="bid"><br>
    价格:<input type="text" name="sprice"><br>
    上架时间:<input type="date" name="stime"><br>
    <input type="button" value="添加" onclick="toadd()">
</body>
</html>
